package com.samba.entites;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.*;

/**
 * Entity implementation class for Entity: Utilisateur
 *
 */
@Entity
@NamedQueries({
	@NamedQuery(name = "findAllUtilisateurs", query = "SELECT u FROM Utilisateur u"),
	@NamedQuery(name = "findAllUtilisateurByid", query = "SELECT u FROM Utilisateur u WHERE u.id = :id"),
	@NamedQuery(name = "findUtilisateurBymail",query="SELECT u FROM Utilisateur u WHERE u.email =  :email"),
	@NamedQuery(name = "identifyUtilisateur", query = "SELECT u FROM Utilisateur u WHERE u.email= :email AND  u.password= :password")
})
@Table(name="TABLE_UTILISATEUR")
@SequenceGenerator(name = "SeqUtilisateur", sequenceName = "utilisateurs_seq")
@Inheritance(strategy = 
InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
   name= "TYPE_UIL", discriminatorType= DiscriminatorType.STRING, length=1)
public abstract class Utilisateur implements Serializable {
	@Id
	@GeneratedValue(strategy= GenerationType.SEQUENCE, generator = "SeqUtilisateur")
	private int id;
	
	
	private String nom;
	private String prenom;
	private BigDecimal fax;
	private String email;
	private BigDecimal telephone;
	private String password;
	private boolean  actif;
	private int level;
	

		@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name= "ADRESSE_FK")
	private Adresse adresseFk;
		
	//private Set<Projet> ensembleProjets;
	
	
	private static final long serialVersionUID = 1L;
	
	public Utilisateur(){
		super();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public BigDecimal getFax() {
		return fax;
	}

	public void setFax(BigDecimal fax) {
		this.fax = fax;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public BigDecimal getTelephone() {
		return telephone;
	}

	public void setTelephone(BigDecimal telephone) {
		this.telephone = telephone;
	}

	public boolean isActif() {
		return actif;
	}

	public void setActif(boolean actif) {
		this.actif = actif;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public Adresse getAdresseFk() {
		return adresseFk;
	}

	public void setAdresseFk(Adresse adresseFk) {
		this.adresseFk = adresseFk;
	}

	/*public Set<Projet> getEnsembleProjets() {
		return ensembleProjets;
	}

	public void setEnsembleProjets(Set<Projet> ensembleProjets) {
		this.ensembleProjets = ensembleProjets;
	}*/

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((nom == null) ? 0 : nom.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Utilisateur other = (Utilisateur) obj;
		if (nom == null) {
			if (other.nom != null)
				return false;
		} else if (!nom.equals(other.nom))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Utilisateur [nom=" + nom + "]";
	}

	
}
